package com.dsprun.dspai.dto;

import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.Data;

import java.util.Map;

@Data
public class ActionRequest {
    private String action;
    private Map<String, Object> parameters;


    public static ActionRequest parseActionRequest(String json) {
        try {
            String cleanJson = json.replaceAll("^```(json)?|```$", "").trim();
            return new ObjectMapper().readValue(cleanJson, ActionRequest.class);
        } catch (Exception e) {
            throw new RuntimeException("动作解析失败", e);
        }
    }
}